package dp;

/**
 * 1646. 获取生成数组中的最大值
 */
public class P1646 {
    public int getMaximumGenerated(int n) {
        if (n <= 1) {
            return n;
        }
        int[] nums = new int[n + 1];
        int max = 1;
        nums[0] = 0;
        nums[1] = 1;
        for (int i = 1; i <= n / 2; i++) {
            if (2 <= 2 * i && 2 * i <= n) {
                nums[2 * i] = nums[i];
            }
            if (2 <= 2 * i + 1 && 2 * i + 1 <= n) {
                nums[2 * i + 1] = nums[i] + nums[i + 1];
                if(nums[2*i+1]>max){
                    max=nums[2*i+1];
                }
            }
        }
        return max;
    }

    public static void main(String[] args) {
        int maximumGenerated = new P1646().getMaximumGenerated(15);
        System.out.println(maximumGenerated);
    }
}
